package cn.com.petrochina.lpm3.util;

import java.sql.ResultSet;
import java.sql.SQLException;

public class SqlUtil {
    public static Object getColumnValue(ResultSet rs, String columnTypeName, String columnLabel) throws SQLException {
        if (columnTypeName.equals("DATE")) {
            return rs.getDate(columnLabel);
        } else if (columnTypeName.equals("NUMBER")) {
            String s = rs.getString(columnLabel);
            if (s == null) return 0;
            if (s.contains(".")) {
                return rs.getFloat(columnLabel);
            } else {
                return rs.getInt(columnLabel);
            }
        } else {
            return rs.getString(columnLabel) == null ? "" : rs.getString(columnLabel);
        }
    }
}
